package klassen;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import Database.*;

public class ISPLAYING {
	
	private int FIELDID;
	private int PLAYERID;
	private int GAMEID;
	private String NAME; 
	private int Money;

	
	
	public ISPLAYING(int playerID, int gameID, String name){
		PLAYERID = playerID;
		GAMEID = gameID;
		NAME = name;
		
	}
	
	
	public int getFIELDID() {
		return FIELDID;
	}
	public static void setFIELDID(int FIELDID) throws SQLException {
		Database.DbVerbindung.connectDB();
		PreparedStatement stmt = null;
		
		try{
		PLAYER player = new PLAYER();
		
		
		String sql = "UPDATE ISPLAYING SET FIELDID = ? WHERE PLAYERID = ? AND GAMEID = ?";
		stmt = Database.DbVerbindung.conn.prepareStatement(sql);
		
		stmt.setInt(1, player.getFIELDID()); 
		stmt.setInt(2, player.getPLAYERID());
		stmt.setInt(3, player.getGAMEID());
		stmt.executeUpdate();
		
		player.FIELDID = FIELDID;
	}
	catch(SQLException e){
		System.out.println("Fehler" + e);
	}
	finally{
		stmt.close();
		Database.DbVerbindung.closeDB(); 
	}
	}
	
	public int getPLAYERID() {
		return PLAYERID;
	}
	
	public int getGAMEID() {
		return GAMEID;
	}
	
	public String getNAME() {
		return NAME;
	}
	

}

